package com.qisu.converters;

import org.springframework.stereotype.Component;

import com.qisu.util.ByteArrayUtils;

/**
 *
 * @author alsan
 *
 */
@Component
public final class IntConverter implements FieldConverter<Integer> {

	@Override
	public Integer converter(byte[] data, int pos, int len) {
		if(null != data && data.length >= 2) {
			return ByteArrayUtils.getInteger(data, pos, len, true);
		}
		return 0;
	}

	@Override
	public Integer converter(byte[] data) {
		return converter(data, 0, 2);
	}

}
